import { http } from '@/utils/http/axios';
import qs from 'qs';

export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  result: T;
}

/**
 * @description: 称重列表
 */
export function getWeightPage(params?) {
  return http.request({
    url: '/weight/weight/page',
    method: 'POST',
    params,
    // // 加这个是解决 传递数组时 会在参数名后面加上[]
    // paramsSerializer: function (params) {
    //   return qs.stringify(params, { arrayFormat: 'repeat' });
    // },
  });
}

export function exportExcel(params?) {
  return http.request({
    url: '/weight/weight/exportExcel',
    method: 'GET',
    params,
    responseType: 'blob', // 设置响应类型为blob，用于文件下载
    // // 加这个是解决 传递数组时 会在参数名后面加上[]
    // paramsSerializer: function (params) {
    //   return qs.stringify(params, { arrayFormat: 'repeat' });
    // },
  }, {
    isTransformResponse: false, // 不转换响应数据
    isReturnNativeResponse: true, // 返回原始响应对象
  });
}

export function getCurrentDayData(params?) {
  return http.request({
    url: '/weight/weight/getCurrentDayData',
    method: 'GET',
    params,
  });
}

export function getCurrentGoodsType(params?) {
  return http.request({
    url: '/weight/weight/getCurrentGoodsType',
    method: 'GET',
    params,
  });
}
export function getLastSevenDayAveragePrice(params?) {
  return http.request({
    url: '/weight/weight/getLastSevenDayAveragePrice',
    method: 'GET',
    params,
  });
}
export function getPriceTrendByGoodsType(goodsType: number) {
  return getLastSevenDayAveragePrice({ goodsType });
}
// export const getLastMonthDayFee(params?) {
//   return http.request({
//     url: '/weight/weight/getLastMonthDayFee',
//     method: 'GET',
//     params,
//   });
// };

export const getLastMonthDayFee = (params?) => {
  return http.request({
    url: '/weight/weight/getLastMonthDayFee',
    method: 'get',
    params,
  });
};

export function getLastMonthDayFeeByGoodsType (goodsType: number){
   return getLastMonthDayFee({ goodsType });
};

export const getCurrentWeightNumberUse = (params?) => {
  return http.request({
    url: '/weight/weight/getCurrentWeightNumberUse',
    method: 'get',
    params,
  });
};

export function getCurrentWeightNumberUseByGoodsType (goodsType: number){
   return getCurrentWeightNumberUse({ goodsType });
};

// export function getOrderItemList(params?) {
//   return http.request<BasicResponseModel>({
//     url: `/order/order/item/list`,
//     method: 'GET',
//     params,
//   });
// }
// /**
//  * 获取物流公司列表
//  * @param params
//  */
// export function getLogisticsList(params?) {
//   return http.request({
//     url: '/order/order/logistics',
//     method: 'GET',
//     params,
//   });
// }
// /**
//  * 订单发货
//  * @param params
//  */
// export function orderShipment(params?) {
//   return http.request<BasicResponseModel>(
//     {
//       url: `/order/order/shipment`,
//       method: 'PUT',
//       params,
//     },
//     {
//       isTransformResponse: false,
//       joinParamsToUrl: true,
//     }
//   );
// }
